package com.example.myapplication

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import org.hades.corelib.base.di.IoDispatcher
import org.hades.corelib.base.exception.ApiException
import org.hades.corelib.base.usecase.FlowUseCase
import javax.inject.Inject


class TestUseCase @Inject constructor(
    @IoDispatcher dispatcher: CoroutineDispatcher,

    ) : FlowUseCase<TestUseCase.Params, TestResult>(dispatcher) {
    override fun execute(parameters: Params): Flow<TestResult> {
        return flow {
            // 通过respository获取网络数据
            emit(TestResult("发送数据～～"))
            delay(800L)
            throw ApiException(6,"API 异常")
        }
    }

    class Params : RequestValues{
        var str:String
        constructor(str: String) {
            this.str = str
        }
    }
}